package com.wuliu.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuliu.common.annotation.Log;
import com.wuliu.common.core.controller.BaseController;
import com.wuliu.common.core.domain.AjaxResult;
import com.wuliu.common.enums.BusinessType;
import com.wuliu.system.domain.SysDeptFormula;
import com.wuliu.system.service.ISysDeptFormulaService;
import com.wuliu.common.utils.poi.ExcelUtil;
import com.wuliu.common.core.page.TableDataInfo;

/**
 * 站点运费公式Controller
 * 
 * @author realue
 * @date 2023-11-03
 */
@Api(tags = {"运费公式控制器"})
@RestController
@RequestMapping("/system/formula")
public class SysDeptFormulaController extends BaseController {
    @Resource
    private ISysDeptFormulaService sysDeptFormulaService;

    /**
     * 查询站点运费公式列表
     */
    @ApiOperation(value = "查询")
    @PreAuthorize("@ss.hasPermi('system:formula:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysDeptFormula sysDeptFormula) {
        startPage();
        List<SysDeptFormula> list = sysDeptFormulaService.selectSysDeptFormulaList(sysDeptFormula);
        return getDataTable(list);
    }

    /**
     * 导出站点运费公式列表
     */
    @ApiOperation(value = "导出")
    @PreAuthorize("@ss.hasPermi('system:formula:export')")
    @Log(title = "站点运费公式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysDeptFormula sysDeptFormula) {
        List<SysDeptFormula> list = sysDeptFormulaService.selectSysDeptFormulaList(sysDeptFormula);
        ExcelUtil<SysDeptFormula> util = new ExcelUtil<SysDeptFormula>(SysDeptFormula.class);
        util.exportExcel(response, list, "站点运费公式数据");
    }

    /**
     * 获取站点运费公式详细信息
     */
    @ApiOperation(value = "详细")
    @PreAuthorize("@ss.hasPermi('system:formula:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(sysDeptFormulaService.selectSysDeptFormulaById(id));
    }

    /**
     * 新增站点运费公式
     */
    @ApiOperation(value = "新增")
    @PreAuthorize("@ss.hasPermi('system:formula:add')")
    @Log(title = "站点运费公式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysDeptFormula sysDeptFormula) {
        return toAjax(sysDeptFormulaService.insertSysDeptFormula(sysDeptFormula));
    }

    /**
     * 修改站点运费公式
     */
    @ApiOperation(value = "编辑")
    @PreAuthorize("@ss.hasPermi('system:formula:edit')")
    @Log(title = "站点运费公式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysDeptFormula sysDeptFormula) {
        return toAjax(sysDeptFormulaService.updateSysDeptFormula(sysDeptFormula));
    }

    /**
     * 删除站点运费公式
     */
    @ApiOperation(value = "删除")
    @PreAuthorize("@ss.hasPermi('system:formula:remove')")
    @Log(title = "站点运费公式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(sysDeptFormulaService.deleteSysDeptFormulaByIds(ids));
    }
}
